package corp;

import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.Map;

public class ControlAccount {
	
	private String controlAccountNumber;
	private String controlAccountName;
	
	private int controlAccBalance;
	
	private Map<String, CardAccount> cardAccounts = new HashMap<String, CardAccount>();

	private Map<String, Object> additionalData = new HashMap<String, Object>();;
	
	public ControlAccount(String controlAccountNumber, String controlAccountName) {
		this.setControlAccountNumber(controlAccountNumber);
		this.setControlAccountName(controlAccountName);
		controlAccBalance = 0;
	}
	
	public String getControlAccountNumber() {
		return controlAccountNumber;
	}

	public void setControlAccountNumber(String controlAccountNumber) {
		this.controlAccountNumber = controlAccountNumber;
	}
	
	public boolean addCardAccount(CardAccount acc) {
		String s = acc.getCardNumber();
		if (cardAccounts.get(s) == null) {
			cardAccounts.put(s, acc);
			return true;
		}
		return false;
	}
	
	public void removeCardAccount(CardAccount acc) {
		String s = acc.getCardNumber();
		cardAccounts.remove(s);
	}
	
	public void debitControlAccount(int amount) {
		controlAccBalance += amount;
	}
	
	public void creditControlAccount(int amount) {
		controlAccBalance -= amount;
	}
	
	public CardAccount getCardAccount(String s) {
		return cardAccounts.get(s);
	}
	
	public Map<String, CardAccount> getCardAccounts() {
		return cardAccounts;
	}

	public String getControlAccountName() {
		return controlAccountName;
	}

	public void setControlAccountName(String controlAccountName) {
		this.controlAccountName = controlAccountName;
	}

	public Object getAdditionalData(String key) {
		return additionalData.get(key);
	}

	public void setAdditionalData(String key, Object data) {
		additionalData.put(key, data);
	}

}
